import React,{ useState } from 'react'
import PubSub from 'pubsub-js'
export default function Gege() {
    const [car,setCar]=useState('二手三轮')

    const changeCarHandle=()=>{
        setCar('一手拖拉机')
        //当换车以后发布数据
        PubSub.publish('qiche','一手拖拉机')
    }
  return (  
    <div>
        <h1>我是哥哥 我开{car}</h1>
        <button onClick={changeCarHandle}>换车</button>
    </div>
  )
}
